import WhiteboardEngine from '@/views/office/whiteboard/engine.vue'
import WhiteboardView from '@/views/office/whiteboard/index.vue'
import MindView from '@/views/office/mind/index.vue'
import MindEngine from '@/views/office/mind/engine.vue'
import WordView from '@/views/office/word/index.vue'
import WordEngine from '@/views/office/word/engine.vue'
import ExcelView from '@/views/office/excel/index.vue'
import ExcelEngine from '@/views/office/excel/engine.vue'
import Views from '@/views/lowcode/index.vue'
import ViewConfig from '@/views/lowcode/engine.vue'
import Job from '@/views/job/index.vue'
import ApiDetail from '@/views/restapi/detail.vue'
import Api from '@/views/restapi/index.vue'
import ProcessList from '@/views/process/ProcessList.vue'
import Flow from '@/views/process/flow.vue'
import ProcessVersionManager from '@/views/process/ProcessVersionManager.vue'
import ideApi from '@/api/ide/ideApi'

import officeApi from '@/api/office/officeApi'
import viewConfigApi from '@/api/viewConfig/viewConfigApi'
import jobApi from '@/api/job/jobApi'
import restApi from '@/api/rest/restApi'
import processApi from '@/api/process/processApi'
import processVersionApi from '@/api/process/processVersionApi'

export const config = [
	{
		type: 'whiteboard',
		isLeafFlag: true,
		icon: `<svg  t="1728726412728" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1595" width="15" height="15"><path d="M932.736 805.184h-29.568c17.728-24 28.608-53.44 28.608-85.568V305.856a145.024 145.024 0 0 0-144.768-144.896h-547.84a144.96 144.96 0 0 0-144.768 144.896v413.76c0 32.128 10.88 61.568 28.672 85.568h-29.44a31.744 31.744 0 1 0 0 63.488h839.104a31.744 31.744 0 1 0 0-63.488zM158.464 305.856c0-44.608 36.224-80.896 80.768-80.896h547.84c44.48 0 80.768 36.288 80.768 80.896v413.76c0 44.48-36.224 80.704-80.768 80.704H447.744c0.192-1.408 0.832-2.688 0.832-4.096v-0.768a32.064 32.064 0 0 0-32-31.936H287.68c-17.6 0-32 14.4-32 31.936v0.768c0 1.408 0.64 2.688 0.832 4.096h-17.28a80.768 80.768 0 0 1-80.768-80.704V305.856z" p-id="1596"></path></svg>`,
		menuItem: [
			{
				key: 'addWhiteboard',
				show: (data) => {
					return data.id != '0' && data.type == 'group'
				},
				text: '新增whiteboard'
			}
		],
		dataMainName: 'workName',
		tabView: WhiteboardEngine,
		loadData: async (groupId, productId) => {
			return await officeApi.queryList({
				groupId: groupId,
				productId: productId,
				typeCode: 'whiteboard'
			})
		},
		operatorView: WhiteboardView
	},
	{
		type: 'mind',
		isLeafFlag: true,
		icon: `<svg t="1728724464083" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5184" width="15" height="15"><path d="M610.88 0l326.84 341.343v563.171c0 65.959-36.384 119.458-102.967 119.458H214.79c-66.582 0.028-128.51-53.47-128.51-119.458V119.486C86.28 53.47 148.207 0 214.79 0h396.09z" fill="#E94848" p-id="5185"></path><path d="M717.481 452.314c2.384 0.624 4.825 1.078 7.152 1.93 7.152 2.725 9.48 8.912 9.31 16.745-0.228 10.842-0.937 21.57-3.86 32.156-5.393 19.583-17.03 32.553-33.86 40.273-11.863 5.393-24.322 7.38-36.895 8.912-8.685 1.05-17.313 2.299-25.97 3.548a11.778 11.778 0 0 0-3.405 1.135c-4.626 2.27-5.818 6.641-2.412 10.53 3.547 4.03 7.464 7.72 11.58 11.011 15.524 12.403 31.474 24.153 46.687 36.953a186.75 186.75 0 0 1 43.764 51.881c11.267 20.15 16.972 42.09 16.234 66.129-0.199 6.357-2.98 10.018-8.742 10.302-8.911 0.454-17.823 0.54-26.763 0.624-11.07 0.114-22.138 0.057-33.207 0.086-11.295 0-22.591 0-33.887 0.056-8.06 0-16.12 0.142-24.21 0.142-2.355 0-4.71-0.085-7.095-0.312-10.047-0.908-13.765-4.995-14.758-16.092-1.476-15.78-3.775-31.248-9.564-45.808a121.416 121.416 0 0 0-45.836-56.82c-17.597-11.976-36.726-19.469-57.501-21.37-20.52-1.874-39.592 2.384-54.918 19.668-9.252 10.473-14.36 23.358-17.909 37.094-1.646 6.216-3.036 12.488-4.824 18.647-2.044 6.982-7.493 8.43-13 8.628-12.033 0.426-24.095 0.426-36.129 0.54-11.068 0.084-22.137 0.113-33.234 0.17-10.217 0.056-20.435 0.226-30.652 0.141a33.774 33.774 0 0 1-7.947-1.334c-3.86-0.965-5.392-3.349-5.194-7.663 1.334-26.196 11.325-47.538 30.425-63.744 15.723-13.34 33.632-21.627 52.42-27.303 17.824-5.393 35.931-9.593 53.868-14.446 5.052-1.362 10.104-2.838 14.929-4.882 7.748-3.292 9.025-8.684 2.895-14.616a138.047 138.047 0 0 0-19.1-15.184c-17.966-12.147-36.5-23.33-52.875-38.145-16.745-15.212-30.822-32.752-38.457-55.798-4.03-12.118-5.705-24.691-5.676-37.633 0-4.967 2.27-8.827 7.35-10.076a89.924 89.924 0 0 1 18.193-2.469c13.765-0.397 27.53-0.227 41.295-0.255l33.234 0.057c8.174 0 16.348-0.114 24.522-0.086 3.775 0 7.521 0.199 11.296 0.284 6.329 0.142 9.082 2.327 10.274 9.224 1.447 8.117 2.412 16.348 3.69 24.522 4.427 29.318 14.985 54.918 36.157 73.876 14.588 13.056 31.56 19.13 50.377 19.98 9.849 0.455 19.583 0.285 29.12-3.235 14.644-5.392 21.768-17.596 20.377-34.483-0.596-7.777-1.107-15.61-1.56-23.415-0.313-5.307 1.277-8.514 6.073-9.479 5.96-1.22 12.147-1.646 18.25-1.731 12.146-0.199 24.294 0.113 36.44 0.17 11.07 0.057 22.138-0.028 33.207 0.057 6.812 0.057 13.538 0.312 20.321 0.51v0.398" fill="#FFFFFF" p-id="5186"></path><path d="M937.72 341.343H737.519c-66.582 0-140.374-58.948-140.374-124.878V0.625l340.577 340.718z" fill-opacity=".255" p-id="5187"></path></svg>`,
		menuItem: [
			{
				key: 'addMind',
				show: (data) => {
					return data.id != '0' && data.type == 'group'
				},
				text: '新增mind'
			}
		],
		dataMainName: 'workName',
		tabView: MindEngine,
		loadData: async (groupId, productId) => {
			return await officeApi.queryList({
				groupId: groupId,
				productId: productId,
				typeCode: 'mind'
			})
		},
		operatorView: MindView
	},
	{
		type: 'word',
		isLeafFlag: true,
		icon: `<svg  t="1728719705490" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6422" width="15" height="15"><path d="M145.6 0C100.8 0 64 35.2 64 80v862.4C64 987.2 100.8 1024 145.6 1024h732.8c44.8 0 81.6-36.8 81.6-81.6V324.8L657.6 0h-512z" fill="#14A9DA" p-id="6423"></path><path d="M960 326.4v16H755.2s-100.8-20.8-99.2-108.8c0 0 4.8 92.8 97.6 92.8H960z" fill="#0F93D0" p-id="6424"></path><path d="M657.6 0v233.6c0 25.6 17.6 92.8 97.6 92.8H960L657.6 0z" fill="#FFFFFF" p-id="6425"></path><path d="M291.2 862.4h-48c-9.6 0-17.6-8-17.6-17.6v-158.4c0-9.6 8-16 17.6-16h48c60.8 0 99.2 41.6 99.2 96s-38.4 96-99.2 96z m0-171.2h-41.6v148.8h41.6c48 0 75.2-33.6 75.2-73.6 0-41.6-27.2-75.2-75.2-75.2z m232 174.4c-57.6 0-96-43.2-96-99.2s38.4-99.2 96-99.2c56 0 94.4 41.6 94.4 99.2 0 56-38.4 99.2-94.4 99.2z m0-177.6c-43.2 0-70.4 33.6-70.4 78.4 0 44.8 27.2 76.8 70.4 76.8 41.6 0 70.4-32 70.4-76.8S564.8 688 523.2 688z m294.4 6.4c1.6 1.6 3.2 4.8 3.2 8 0 6.4-4.8 11.2-11.2 11.2-3.2 0-6.4-1.6-8-3.2-11.2-14.4-30.4-22.4-48-22.4-41.6 0-73.6 32-73.6 78.4 0 44.8 32 76.8 73.6 76.8 17.6 0 35.2-6.4 48-20.8 1.6-3.2 4.8-4.8 8-4.8 6.4 0 11.2 6.4 11.2 12.8 0 3.2-1.6 4.8-3.2 8-14.4 16-35.2 27.2-64 27.2-56 0-99.2-40-99.2-99.2s43.2-99.2 99.2-99.2c28.8 0 49.6 11.2 64 27.2z" fill="#FFFFFF" p-id="6426"></path></svg>`,
		menuItem: [
			{
				key: 'addWord',
				show: (data) => {
					return data.id != '0' && data.type == 'group'
				},
				text: '新增word'
			}
		],
		dataMainName: 'workName',
		tabView: WordEngine,
		loadData: async (groupId, productId) => {
			return await officeApi.queryList({
				groupId: groupId,
				productId: productId,
				typeCode: 'word'
			})
		},
		operatorView: WordView
	},
	{
		type: 'excel',
		isLeafFlag: true,
		icon: `<svg  t="1728717188187" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4349" width="15" height="15"><path d="M855.733157 63.83998 168.264796 63.83998c-57.672514 0-104.425328 46.752814-104.425328 104.426351l0 687.46836c0 57.672514 46.752814 104.425328 104.425328 104.425328L855.733157 960.16002c57.672514 0 104.425328-46.752814 104.425328-104.425328L960.158485 168.266331C960.158485 110.592794 913.406694 63.83998 855.733157 63.83998zM665.702126 731.750913l-63.856353 0-71.352071-128.613216c-6.999414-12.591783-15.093766-28.780487-24.283056-48.567135-10.79281 14.591323-23.984251 30.082132-39.573297 46.468334L344.019683 731.750913l-77.94728 0 209.857589-222.149543L351.514377 292.249087l64.75584 0 56.661488 99.532901c14.989389 26.185382 23.581068 41.4746 25.783223 45.868677 5.194302 9.794064 10.891048 21.48636 17.08819 35.075867 14.787798-19.983123 37.670971-46.267766 68.653613-78.846766l96.534614-101.630678 76.747965 0L545.184285 519.194866 665.702126 731.750913z" fill="#01A408" p-id="4350"></path></svg>`,
		menuItem: [
			{
				key: 'addExcel',
				show: (data) => {
					return data.id != '0' && data.type == 'group'
				},
				text: '新增excel'
			}
		],
		dataMainName: 'workName',
		tabView: ExcelEngine,
		loadData: async (groupId, productId) => {
			return await officeApi.queryList({
				groupId: groupId,
				productId: productId,
				typeCode: 'excel'
			})
		},
		operatorView: ExcelView
	},
	{
		type: 'view',
		isLeafFlag: true,
		icon: `<svg  t="1728285848005" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5170" width="15" height="15"><path d="M213.333333 426.666667h170.666667v170.666666H213.333333v-170.666666z m0-213.333334h170.666667v170.666667H213.333333V213.333333z m213.333334 0h170.666666v170.666667h-170.666666V213.333333z m0 213.333334h170.666666v170.666666h-170.666666v-170.666666z m213.333333-213.333334h170.666667v170.666667h-170.666667V213.333333z m0 213.333334h170.666667v170.666666h-170.666667v-170.666666z m0 213.333333h170.666667v170.666667h-170.666667v-170.666667z m-213.333333 0h170.666666v170.666667h-170.666666v-170.666667z m-213.333334 0h170.666667v170.666667H213.333333v-170.666667z" fill="#f4614e" p-id="5171" data-spm-anchor-id="a313x.search_index.0.i1.26913a81sfBibN" class="selected"></path></svg>`,
		menuItem: [
			{
				key: 'addView',
				show: (data) => {
					return data.id != '0' && data.type == 'group'
				},
				text: '新增视图'
			},
			{
				key: 'publish',
				show: (data) => {
					return data.type == 'view'
				},
				text: (data) => {
					return data.publishFlag == 'OFFLINE' ? '上线' : '下线'
				}
			}
		],
		dataMainName: 'viewName',
		tabView: ViewConfig,
		loadData: async (groupId, productId) => {
			return await viewConfigApi.list({
				groupId: groupId,
				productId: productId
			})
		},
		operatorView: Views
	},
	{
		type: 'job',
		isLeafFlag: true,
		icon: `<svg t="1728219587755" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4348" width="15" height="15"><path d="M512 0C230.4 0 0 230.4 0 512s230.4 512 512 512 512-230.4 512-512S793.6 0 512 0z m0 960C262.4 960 64 761.6 64 512S262.4 64 512 64s448 198.4 448 448-198.4 448-448 448z" p-id="4349" fill="#d4237a"></path><path d="M556.8 518.4V339.2c0-19.2-12.8-32-32-32s-32 12.8-32 32v192c0 6.4 0 19.2 6.4 19.2l198.4 204.8c6.4 6.4 12.8 12.8 25.6 12.8 6.4 0 12.8 0 19.2-6.4 12.8-12.8 12.8-32 0-44.8L556.8 518.4z" p-id="4350" fill="#d4237a"></path></svg>`,
		menuItem: [
			{
				key: 'addJob',
				show: (data) => {
					return data.id != '0' && data.type == 'group'
				},
				text: '新增调度'
			}
		],
		dataMainName: 'jobName',
		tabView: Job,
		loadData: async (groupId, productId) => {
			let list = await jobApi.queryJobConfigList({
				groupId: groupId,
				productId: productId
			})
			return list
		},
		operatorView: Job
	},
	{
		type: 'api',
		isLeafFlag: true,
		icon: `<svg  t="1728204898393" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4326" width="15" height="15"><path d="M341.333333 661.333333a117.376 117.376 0 0 1 112.917334 85.333334H875.093333v64H454.250667a117.376 117.376 0 0 1-225.834667 0H149.76v-64h78.656A117.376 117.376 0 0 1 341.333333 661.333333z m0 64a53.333333 53.333333 0 1 0 0 106.666667 53.333333 53.333333 0 0 0 0-106.666667z m341.333334-320a117.376 117.376 0 0 1 112.917333 85.333334h79.509333v64h-79.509333a117.376 117.376 0 0 1-225.834667 0H149.76v-64h419.989333A117.376 117.376 0 0 1 682.666667 405.333333z m0 64a53.333333 53.333333 0 1 0 0 106.666667 53.333333 53.333333 0 0 0 0-106.666667zM341.333333 149.333333a117.376 117.376 0 0 1 112.917334 85.333334H875.093333v64H454.250667a117.376 117.376 0 0 1-225.834667 0H149.76v-64h78.656A117.376 117.376 0 0 1 341.333333 149.333333z m0 64a53.333333 53.333333 0 1 0 0 106.666667 53.333333 53.333333 0 0 0 0-106.666667z" fill="#1677FF" p-id="4327"></path></svg>`,
		menuItem: [
			{
				key: 'addApi',
				show: (data) => {
					return data.id != '0' && data.type == 'group'
				},
				text: '新增接口'
			},
			{
				key: 'publish',
				show: (data) => {
					return data.type == 'api'
				},
				text: (data) => {
					console.log(data)
					return data.apiStatusCode == 'OFFLINE' ? '上线' : '下线'
				}
			}
		],
		dataMainName: 'apiName',
		tabView: ApiDetail,
		loadData: async (groupId, productId) => {
			const list = await restApi.apiList({
				groupId: groupId,
				productId: productId
			})
			return list
		},
		operatorView: Api
	},
	{
		type: 'process',
		childType: 'processVersion',
		isLeafFlag: false,
		icon: `<svg t="1728181011860" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5354" width="15" height="15"><path d="M988.16 621.568H867.328v-98.304c0-17.408-13.312-30.72-30.72-30.72H545.792v-90.112h120.832c17.408 0 30.72-13.312 30.72-30.72V68.608c0-17.408-13.312-30.72-30.72-30.72H363.52c-17.408 0-30.72 13.312-30.72 30.72v303.104c0 17.408 13.312 30.72 30.72 30.72h120.832v90.112h-296.96c-17.408 0-30.72 13.312-30.72 30.72v98.304H35.84c-17.408 0-30.72 13.312-30.72 30.72v303.104c0 17.408 13.312 30.72 30.72 30.72h303.104c17.408 0 30.72-13.312 30.72-30.72V652.288c0-17.408-13.312-30.72-30.72-30.72H218.112v-67.584h587.776v67.584H685.056c-17.408 0-30.72 13.312-30.72 30.72v303.104c0 17.408 13.312 30.72 30.72 30.72h303.104c17.408 0 30.72-13.312 30.72-30.72V652.288c0-17.408-13.312-30.72-30.72-30.72z m-593.92-522.24h241.664v241.664H394.24V99.328z m-86.016 825.344H66.56V683.008h241.664v241.664z m649.216 0H715.776V683.008h241.664v241.664z" fill="#13227a" p-id="5355"></path></svg>`,
		menuItem: [
			{
				key: 'addProcess',
				show: (data) => {
					return data.id != '0' && data.type == 'group'
				},
				text: '新增流程'
			},
			{
				key: 'addProcessVersion',
				type: 'processVersion',
				show: (data) => {
					return data.type == 'process'
				},
				text: '新增版本'
			}
		],
		dataMainName: 'processName',
		loadData: async (groupId, productId) => {
			return await processApi.queryProcessList({ groupId: groupId, productId: productId })
		},
		operatorView: ProcessList
	},
	{
		type: 'processVersion',
		isLeafFlag: true,
		icon: `<svg t="1728181055348" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6404" width="15" height="15"><path d="M877.35808 696.4992a23.04 23.04 0 0 1 22.38464-40.27904l29.44 16.36352c37.7856 20.992 50.0992 67.28704 26.49088 102.58432a76.42624 76.42624 0 0 1-26.48576 24.2176l-378.33728 210.23744c-24.7296 13.7472-55.5264 13.7472-80.256 0L92.25728 799.3856c-37.7856-20.992-50.09408-67.28704-26.48576-102.58432a76.42624 76.42624 0 0 1 26.48576-24.21248l29.83424-16.57856a23.04 23.04 0 0 1 22.37952 40.27904l-29.82912 16.57856a30.38208 30.38208 0 0 0-10.56768 9.55392c-8.35072 12.48768-4.08064 28.54912 10.56768 36.68992l378.33216 210.24256c10.81344 6.00576 24.6784 6.00576 35.49184 0l378.33728-210.24256a30.38208 30.38208 0 0 0 10.56768-9.55904c8.35072-12.48768 4.08064-28.54912-10.56768-36.6848l-29.44512-16.36352z m-2.432-219.21792a23.04 23.04 0 0 1 22.37952-40.27904l31.88224 17.7152c37.78048 20.992 50.09408 67.28704 26.48576 102.58432a76.42624 76.42624 0 0 1-26.48576 24.2176l-378.33728 210.23744c-24.7296 13.74208-55.5264 13.74208-80.256 0l-378.33728-210.24256c-37.7856-20.992-50.09408-67.28704-26.48576-102.58432a76.42624 76.42624 0 0 1 26.48576-24.2176l31.98976-17.77152a23.04 23.04 0 1 1 22.38464 40.27904l-31.98976 17.77664a30.38208 30.38208 0 0 0-10.56768 9.55392c-8.35072 12.48768-4.08064 28.54912 10.56768 36.6848l378.33216 210.24256c10.81344 6.01088 24.6784 6.01088 35.49184 0l378.33728-210.24256a30.38208 30.38208 0 0 0 10.56768-9.55392c8.35072-12.48768 4.08064-28.54912-10.56768-36.6848l-31.87712-17.7152z m-350.52544-415.18592a28.16 28.16 0 0 0-27.35616 0L117.32992 273.1008a28.16 28.16 0 0 0 0 49.2288l379.71456 211.01056a28.16 28.16 0 0 0 27.35616 0l379.71456-211.01056a28.16 28.16 0 0 0 0-49.2288l-379.71456-211.00544z m402.0992 170.7264c35.84 19.9168 48.7424 65.11616 28.83072 100.95616a74.24 74.24 0 0 1-28.83072 28.83072l-379.71456 211.01056a74.24 74.24 0 0 1-72.12544 0L94.94528 362.60864c-35.84-19.9168-48.74752-65.11616-28.83072-100.95104a74.24 74.24 0 0 1 28.8256-28.83584L474.66496 21.81632a74.24 74.24 0 0 1 72.12544 0l379.71456 211.00544z" fill="#d4237a" p-id="6405"></path></svg>`,
		menuItem: [],
		dataMainName: 'processVersion',
		loadData: async (processId) => {
			const data = await processVersionApi.queryList({
				processId: processId
			})
			return data
		},
		tabView: Flow,
		operatorView: ProcessVersionManager
	}
]

export const loadData = async (groupId, productId) => {
	return await ideApi.list({
		groupId: groupId,
		productId: productId
	})
}
